﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Sockets;
using System.Text;

namespace IntegratedOnBordDebug.UDPCore
{
    /// <summary>DTU 信息存储对象
    /// 
    /// </summary>
    public class ObjectDTU
    {
        private string _mac = "";

        private bool _isonline = true;

        private DateTime _logintime;

        private DateTime _refreshtime;

        private string deviceNo = "";

        private SocketAsyncEventArgs saea;

        private List<byte> revBytes = new List<byte>();

        private System.Drawing.Image _stateImg;

        /// <summary>在线状态
        /// 
        /// </summary>
        public System.Drawing.Image StateImg
        {
            get { return _stateImg; }
            set { _stateImg = value; }
        }

        /// <summary>集中器MAC
        /// 
        /// </summary>
        public string MAC
        {
            get { return _mac; }
            set { _mac = value; }
        }

        /// <summary>登陆时间
        /// 
        /// </summary>
        public DateTime LoginTime
        {
            get
            {
                return this._logintime;
            }
            set
            {
                this._logintime = value;
            }
        }

        /// <summary>最后一次通信时间
        /// 
        /// </summary>
        public DateTime RefreshTime
        {
            get
            {
                return this._refreshtime;
            }
            set
            {
                this._refreshtime = value;
            }
        }

        /// <summary>在线状态：true 在线/false 离线
        /// 
        /// </summary>
        public bool IsOnline
        {
            get
            {
                return this._isonline;
            }
            set
            {
                this._isonline = value;
            }
        }

        /// <summary>DTU 序号
        /// 
        /// </summary>
        public string DeviceNo
        {
            get { return deviceNo; }
            set { deviceNo = value; }
        }

        /// <summary>DTU 通信套接字操作对象
        /// 
        /// </summary>
        public SocketAsyncEventArgs SocketArgs
        {
            get { return saea; }
            set { saea = value; }
        }

        /// <summary>接收到的字节数组
        /// 
        /// </summary>
        public List<byte> RevBytes
        {
            get { return revBytes; }
            set { revBytes = value; }
        }

        /// <summary>客户端IP及端口
        /// 
        /// </summary>
        public string IPString { get; set; }

        /// <summary>深度复制该对象
        /// 
        /// </summary>
        /// <returns></returns>
        public ObjectDTU Clone()
        {
            ObjectDTU obj = new ObjectDTU();
            obj.DeviceNo = this.DeviceNo;
            obj.IPString = this.IPString;
            obj.IsOnline = this.IsOnline;
            obj.LoginTime = this.LoginTime;
            obj.MAC = this.MAC;
            obj.RefreshTime = this.RefreshTime;
            obj.RevBytes = this.RevBytes;
            obj.SocketArgs = this.SocketArgs;
            obj.StateImg = this.StateImg;
            return obj;
        }
    }
}
